//
//  HRUserScoreTableViewCell.m
//  haierapp
//
//  Created by Xia Zhiyong on 14-9-3.
//  Copyright (c) 2014年 haier. All rights reserved.
//

#import "HRUserScoreTableViewCell.h"
#import "HRPointInfo.h"

#define ADD_TXT_COLOR [UIColor colorFromHexRGB:@"ff0000"]
#define LESS_TXT_COLOR [UIColor colorFromHexRGB:@"4fa93a"]

#define LESS_TYPE @"积分兑换"

@implementation HRUserScoreTableViewCell

- (void)awakeFromNib
{

}

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = (HRUserScoreTableViewCell *)[[[NSBundle mainBundle] loadNibNamed:@"HRUserScoreTableViewCell"
                                                                    owner:self
                                                                  options:nil] objectAtIndex:0];
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    
}

-(void)configWithData:(id)data{
    HRPointInfo *info = (HRPointInfo*)data;
    _lblDesc.text = [NSString stringWithFormat:@"%@",info.pointsDesc];
    UIColor *colorTxt = [self textColorByType:info.pointsType];
    _lblPoints.textColor = colorTxt;
    if ([colorTxt isEqual:ADD_TXT_COLOR]) {
        _lblPoints.text = [NSString stringWithFormat:@"+%@",info.points];
    }else{
        _lblPoints.text = [NSString stringWithFormat:@"-%@",info.points];
    }
}

-(UIColor*)textColorByType:(NSString*)type{
    if ([type isEqualToString:LESS_TYPE]) {
        return LESS_TXT_COLOR;
    }else{
        return ADD_TXT_COLOR;
    }
}

@end
